package com.cxhc.web.controller.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.cxhc.system.domain.app.Examination;
import com.cxhc.system.service.app.IExaminationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.annotation.Log;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.enums.BusinessType;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 考试的列Controller
 * 
 * @author Dhq
 * @date 2024-08-18
 */
@RestController
@RequestMapping("/admin/examination")
public class ExaminationController extends BaseController
{
    @Autowired
    private IExaminationService examinationService;

    /**
     * 查询考试的列列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Examination examination)
    {
        startPage();
        List<Examination> list = examinationService.getAllExamination(examination);
        return getDataTable(list);
    }

    /**
     * 获取考试的列详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examinationService.selectExaminationById(id));
    }


    /**
     * 新增考试的列
     */
    @Log(title = "新增考试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid Examination examination)
    {
        return toAjax(examinationService.insertExamination(examination));
    }

    /**
     * 修改考试的列
     */
    @PreAuthorize("@ss.hasPermi('system:examination:edit')")
    @Log(title = "考试的列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Examination examination)
    {
        return toAjax(examinationService.updateExamination(examination));
    }

    /**
     * 删除考试的列
     */
    @PreAuthorize("@ss.hasPermi('system:examination:remove')")
    @Log(title = "考试的列", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examinationService.deleteExaminationByIds(ids));
    }

}
